<template>
  <div class="createPost-container">
    <Tinymce ref="editor" v-model="content" :height="400" />
    <div>
      <el-button type="info" style="margin-top:10px;" @click="cancel">取消</el-button>
      <el-button type="primary" style="margin-top:10px;" @click="submit">确定</el-button>
    </div>
  </div>
</template>

<script>
import Tinymce from '@/components/Tinymce'

export default {
  name: 'AddArticle',
  components: { Tinymce },
  props: {
    onSubmit: {
      type: Function,
      default: () => {}
    },
    onCancel: {
      type: Function,
      default: () => {}
    }
  },
  data() {
    return {
      content: ''
    }
  },
  computed: {
    contentShortLength() {
      return this.postForm.content_short.length
    }
  },
  created() {
  },
  methods: {
    show(content) {
      this.content = content
      this.$refs.editor.setContent(content)
    },
    submit() {
      this.onSubmit(this.content)
    },
    cancel() {
      this.onCancel()
    }
  }
}
</script>

<style lang="scss" scoped>
@import "~@/styles/mixin.scss";

.createPost-container {
  position: relative;

  .createPost-main-container {
    // padding: 40px 45px 20px 50px;

    .postInfo-container {
      position: relative;
      @include clearfix;
      margin-bottom: 10px;

      .postInfo-container-item {
        float: left;
      }
    }
  }

  .word-counter {
    width: 40px;
    position: absolute;
    right: 10px;
    top: 0px;
  }
}

.article-textarea ::v-deep {
  textarea {
    padding-right: 40px;
    resize: none;
    border: none;
    border-radius: 0px;
    border-bottom: 1px solid #bfcbd9;
  }
}
</style>
